//
// Created by yewei on 2023/1/5.
//
#include <bits/stdc++.h>

using namespace std;

int main() {
    freopen("../input.txt", "r", stdin);
    int T;
    cin>>T;
    int k,m,p;
    double a,b;
    double max_res;
    double now=0;
    double x0;
    while(T--){
        cin>>k>>m>>p>>a>>b;
        for(double i=a;i<=b;){
            now = k*pow(i,p)-pow(m,i);
            if(now > max_res) {
                max_res = now;
                x0 = i;
            }
            i+=0.000001;
        }
        printf("%.8lf\n",x0);
    }
}
